/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.hera.process.workflow.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import com.hera.base.domain.BaseDomain;

/**
 *
 * @author cmontes
 */
@Entity
@Table(name = "PROCESS_INSTANCE")
public class ProcessInstance extends BaseDomain implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    //@Id
    //@Basic(optional = false)
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "ProcessInstance")
    @TableGenerator(name = "ProcessInstance", table = "sequence", pkColumnName = "seq_name", valueColumnName = "seq_id", pkColumnValue = "PROCESSINSTANCE", allocationSize = 1)
    @Column(name = "ID_PROCESS_INSTANCE")
    private Long idProcessInstance;
    @Column(name = "ID_CURRENT_STAGE")
    private Long idCurrentStage;
    private String name;
    @Column(name = "END_USER")
    private Long endUser;
    @Column(name = "START_USER")
    private Long startUser;
    @Column(name = "MAX_END_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date maxEndDate;
    @Column(name = "START_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date startDate;
    @Column(name = "END_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date endDate;
    private String description;
    @Column(name = "CURRENT_USER")
    private Long currentUser;
    @Column(name = "CUSTOM_CODE")
    private String customCode;
    private String key;
    private String pin;
    @Column(name = "ID_STATUS")
    private Long idStatus;
    @JoinColumn(name = "ID_PROCESS", referencedColumnName = "ID_PROCESS")
    @ManyToOne
    private Process process;
    //@OneToMany(cascade = CascadeType.ALL, mappedBy = "processInstance")
    @Transient
    private List<ProcInstancHistory> procInstancHistoryList;
    //@OneToMany(mappedBy = "processInstance")
    @Transient
    private List<ProcInstancNote> procInstancNoteList;
    //@OneToMany(mappedBy = "processInstance")
    @Transient
    private List<TaskUser> taskUserList;

    public ProcessInstance() {
    }

    public ProcessInstance(Long idProcessInstance) {
        this.idProcessInstance = idProcessInstance;
    }

    public Long getIdProcessInstance() {
        return idProcessInstance;
    }

    public void setIdProcessInstance(Long idProcessInstance) {
        this.idProcessInstance = idProcessInstance;
    }

    public Long getIdCurrentStage() {
        return idCurrentStage;
    }

    public void setIdCurrentStage(Long idCurrentStage) {
        this.idCurrentStage = idCurrentStage;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getEndUser() {
        return endUser;
    }

    public void setEndUser(Long endUser) {
        this.endUser = endUser;
    }

    public Long getStartUser() {
        return startUser;
    }

    public void setStartUser(Long startUser) {
        this.startUser = startUser;
    }

    public Date getMaxEndDate() {
        return maxEndDate;
    }

    public void setMaxEndDate(Date maxEndDate) {
        this.maxEndDate = maxEndDate;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Long getCurrentUser() {
        return currentUser;
    }

    public void setCurrentUser(Long currentUser) {
        this.currentUser = currentUser;
    }

    public String getCustomCode() {
        return customCode;
    }

    public void setCustomCode(String customCode) {
        this.customCode = customCode;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getPin() {
        return pin;
    }

    public void setPin(String pin) {
        this.pin = pin;
    }

    public Long getIdStatus() {
        return idStatus;
    }

    public void setIdStatus(Long idStatus) {
        this.idStatus = idStatus;
    }

    public Process getProcess() {
        return process;
    }

    public void setProcess(Process process) {
        this.process = process;
    }

    public List<ProcInstancHistory> getProcInstancHistoryList() {
        return procInstancHistoryList;
    }

    public void setProcInstancHistoryList(List<ProcInstancHistory> procInstancHistoryList) {
        this.procInstancHistoryList = procInstancHistoryList;
    }

    public List<ProcInstancNote> getProcInstancNoteList() {
        return procInstancNoteList;
    }

    public void setProcInstancNoteList(List<ProcInstancNote> procInstancNoteList) {
        this.procInstancNoteList = procInstancNoteList;
    }

    public List<TaskUser> getTaskUserList() {
        return taskUserList;
    }

    public void setTaskUserList(List<TaskUser> taskUserList) {
        this.taskUserList = taskUserList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idProcessInstance != null ? idProcessInstance.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof ProcessInstance)) {
            return false;
        }
        ProcessInstance other = (ProcessInstance) object;
        if ((this.idProcessInstance == null && other.idProcessInstance != null) || (this.idProcessInstance != null && !this.idProcessInstance.equals(other.idProcessInstance))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.hera.process.data.domain2.ProcessInstance[ idProcessInstance=" + idProcessInstance + " ]";
    }
    
}
